package org.demo.mine.controller;

import freemarker.template.TemplateException;
import lombok.extern.log4j.Log4j2;
import org.demo.mine.model.BoxDashBoard;
import org.demo.mine.service.BoxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @Author:LiaoYouLe
 * @Date: Created in 2018/8/31
 * @Description
 * @Modifyied By:
 */
@RestController
@Log4j2
public class MineController {
    @Autowired
    private BoxService boxService;
    @Autowired
    private HttpServletRequest request;
    @Autowired
    private BoxDashBoard boxDashBoard;
    @GetMapping("dashboard/data/{id}")
    public Mono<String> boxArea(@PathVariable(value = "id", required = false) Integer id) throws IOException, TemplateException {
        String area = boxService.getBoxArea(id);
        log.info(Thread.currentThread().getId());
        return Mono.just(area);
    }

    @PostMapping("dashboard/reset")
    public void reset() {
        boxDashBoard.reset();
    }

}
